// Show voltage at port A, pin 1 
// Set upper limit with joystick up, lower limit with joystick down
// Illuminate LCD backlight, if voltage out of limits

#include "../../ACUAS/ACUAS.h"
#include "../../ACUAS/ACUASlcd.h"

PROGRAM_INIT
	VAR16(mvolt) VAR16(lmvolt=0) VAR16(umvolt=5000)

	ACTIVATE_ADC
	ADC_CHANNEL(1)

	ACTIVATE_LCD	
	CLEAR_LCD
	LCD_BAR_V_INIT

PROGRAM_START
	ADCONVERT_MV(mvolt)

	ON_JOYSTICK_DOWN lmvolt = mvolt;
	ON_JOYSTICK_UP   umvolt = mvolt;
	if(mvolt<lmvolt || mvolt>umvolt) LCD_BACKLIGHT_ON
	else LCD_BACKLIGHT_OFF

	LCD_XY(1,1)
	LCD_D_NUMBER(mvolt/1000.,4,2)
	LCD_TEXT(" Volt")

	LCD_BAR_V(mvolt,0,5000,13)
	LCD_XY(15,1) LCD_TEXT("5V")
	LCD_XY(15,2) LCD_TEXT("0V")

PROGRAM_END
